package com.cy.dbsys.controller;

import com.cy.commom.pojo.JsonResult;
import com.cy.dbsys.pojo.SysMenu;
import com.cy.dbsys.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/menu")
@RestController
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;


    /**5、基于id修改菜单信息*/
    @RequestMapping("/doUpdateObject")
    public JsonResult doUpdateObject(SysMenu entity){
        sysMenuService.updateObject(entity);
        return new JsonResult("update ok");
    }

    /**4、保存菜单信息*/
    @RequestMapping("/doSaveObject")
    public JsonResult doSaveObject(SysMenu entity){
        sysMenuService.saveObject(entity);
        return new JsonResult("save ok");
    }

    /**3、查询上级菜单信息*/
    @RequestMapping("/doFindZtreeMenuNodes")
    public JsonResult doFindZtreeMenuNodes(){
        return new JsonResult(sysMenuService.findZtreeMenuNodes());
    }

    /**2、基于菜单id删除数据*/
    @RequestMapping("/doDeleteObject")
    public JsonResult doDeleteObject(Integer id){
        System.out.println(id);
        sysMenuService.deleteObject(id);
        return new JsonResult("delete ok");
    }

    /**1、查询所有数据*/
    @RequestMapping("/doFindObjects")
    public JsonResult doFindObjects(){
        return new JsonResult(sysMenuService.findObjects());
    }
}
